﻿@using FE.Shared
@using FE.Shared.Enum
@model FE.Shared.MySqlSettings

<style>
    .msg {
        width: 50%;
        margin: 20px;
    }
</style>

<form asp-action="Update">
    <!-- general form elements -->
    <div class="card card-primary">
        <div class="card-header">
            <h3 class="card-title">数据库设置</h3>
        </div>
        <!-- /.card-header -->
        <div class="card-body">
            <h4>目前仅支持Mysql数据库</h4>
            <div class="form-group">
                <label for="exampleInputBorder">数据库服务器地址:</label>
                <input type="text" class="form-control form-control-border" asp-for="HostIp" placeholder="127.0.0.1">
            </div>
            <div class="form-group">
                <label for="exampleInputBorderWidth2">数据库服务器端口号: </label>
                <input type="text" class="form-control form-control-border border-width-2" asp-for="Port" placeholder="3306">
            </div>
            <div class="form-group">
                <label for="exampleInputBorderWidth2">数据库名称: </label>
                <input type="text" class="form-control form-control-border border-width-2" asp-for="DatabaseName" placeholder="fe_base5">
            </div>
            <div class="form-group">
                <label for="exampleInputRounded0">数据库账号:</label>
                <input type="text" class="form-control rounded-0" asp-for="Username" placeholder="fe">
            </div>
            <div class="form-group">
                <label for="exampleInputRounded0">数据库密码:</label>
                <input type="password" class="form-control rounded-0" asp-for="Password" placeholder="Password">
            </div>
        </div>
        <div class="card-footer">
            <button type="submit" class="btn btn-primary">保存和测试连接</button>
        </div>



        @if (ViewBag?.ResultCode == ResultCode.Normal)
        {

        }
        else if (ViewBag?.ResultCode == ResultCode.Failed)
        {
            <div class="col-md-6 col-sm-6 col-6">
                <div class="info-box bg-danger">
                    <span class="info-box-icon"><i class="fas fa-comments"></i></span>

                    <div class="info-box-content">
                        <span class="info-box-text">Failed!</span>
                        <span class="info-box-number"></span>

                        <div class="progress">
                            <div class="progress-bar" style="width: 100%"></div>
                        </div>
                        <span>
                            详细信息:@ViewBag.Msg
                        </span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
        }
        else if (ViewBag?.ResultCode == ResultCode.Success)
        {
            <div class="col-md-6 col-sm-6 col-6">
                <div class="info-box bg-success">
                    <span class="info-box-icon"><i class="far fa-thumbs-up"></i></span>

                    <div class="info-box-content">
                        <span class="info-box-text">Successfully!</span>
                        <span class="info-box-number"></span>

                        <div class="progress">
                            <div class="progress-bar" style="width: 100%"></div>
                        </div>
                        <span class="progress-description">
                            保存成功,数据库连接正常!
                        </span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
        }



    </div>
</form>

